#include<stdio.h>
int main()
{
	int N,a[5050]={0};
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		int qq,b,c;
		scanf("%d %d %d",&qq,&b,&c);
		a[i]=qq*10000+b*100+c;
	}
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			if(a[i]>a[j])
			{
				int ss;
				ss=a[i];
				a[i]=a[j];
				a[j]=ss;
			}
		}
	}
	for(int i=0;i<N;i++)
	{
		int bb;
		bb=a[i]/10000;
		if(bb<10)
		{
		printf("0%d ",bb);
		}
		else
		printf("%d ",bb);
		
		bb=a[i]/100;
		if(bb%100<10)
		
		printf("0%d ",bb%100);
		else
		printf("%d ",bb%100);
		
		if(a[i]%100<10)
		printf("0%d\n",a[i]%100);
		else
		printf("%d\n",a[i]%100);
	
	}
	return 0;
}